using MaterialUI;
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class Example19 : MonoBehaviour
{
	[SerializeField]
	private Image m_ColorImage1;

	[SerializeField]
	private Image m_ColorImage2;

	[SerializeField]
	private Image m_ColorImage3;

	[SerializeField]
	private Image m_ColorImage4;

	[SerializeField]
	private Image[] m_ColorImagesArray1;

	[SerializeField]
	private Image[] m_ColorImagesArray2;

	[SerializeField]
	private Image[] m_ColorImagesArray3;

	[SerializeField]
	private AnimationCurve m_AnimCurve;

	private int m_SavedId = -1;

	public void Simple1(bool isRed)
	{
		Color targetValue = (!isRed) ? MaterialColor.blue500 : MaterialColor.red500;
		TweenManager.TweenColor(delegate(Color color)
		{
			m_ColorImage1.color = color;
		}, m_ColorImage1.color, targetValue, 1f);
	}

	public void Simple2(bool isRed)
	{
		Color targetValue = (!isRed) ? MaterialColor.blue500 : MaterialColor.red500;
		float delay = (!isRed) ? 0.5f : 0f;
		Action callback = null;
		if (isRed)
		{
			callback = delegate
			{
				ToastManager.Show("Red tween finished!");
			};
		}
		TweenManager.TweenColor(delegate(Color color)
		{
			m_ColorImage2.color = color;
		}, m_ColorImage2.color, targetValue, 1f, delay, callback);
	}

	public void Advanced1(bool isRed)
	{
		if (isRed)
		{
			TweenManager.TweenColorCustom(delegate(Color color)
			{
				m_ColorImage3.color = color;
			}, m_ColorImage3.color, MaterialColor.red500, 1f, m_AnimCurve);
		}
		else
		{
			TweenManager.TweenColor(delegate(Color color)
			{
				m_ColorImage3.color = color;
			}, m_ColorImage3.color, MaterialColor.blue500, 1f, 0f, null, scaledTime: false, Tween.TweenType.Linear);
		}
	}

	public void Advanced2(int buttonType)
	{
		TweenManager.EndTween(m_SavedId);
		Color targetValue;
		switch (buttonType)
		{
		case 0:
			return;
		case 1:
			targetValue = MaterialColor.red500;
			break;
		default:
			targetValue = MaterialColor.blue500;
			break;
		}
		m_SavedId = TweenManager.TweenColor(delegate(Color color)
		{
			m_ColorImage4.color = color;
		}, m_ColorImage4.color, targetValue, 1f, 0f, null, scaledTime: false, Tween.TweenType.Linear);
	}

	public void Issue(bool isRed)
	{
		StartCoroutine(IssueCoroutine(isRed));
	}

	private IEnumerator IssueCoroutine(bool isRed)
	{
		Color targetColor = (!isRed) ? MaterialColor.blue500 : MaterialColor.red500;
		for (int j = 0; j < m_ColorImagesArray1.Length; j++)
		{
			int i = j;
			TweenManager.TweenColor(delegate(Color color)
			{
				m_ColorImagesArray1[i].color = color;
			}, m_ColorImagesArray1[i].color, targetColor, 1.5f, 0f, null, scaledTime: false, Tween.TweenType.Linear);
			yield return new WaitForSeconds(0.5f);
		}
	}

	public void Workaround1(bool isRed)
	{
		Color targetValue = (!isRed) ? MaterialColor.blue500 : MaterialColor.red500;
		for (int j = 0; j < m_ColorImagesArray2.Length; j++)
		{
			int i = j;
			TweenManager.TweenColor(delegate(Color color)
			{
				m_ColorImagesArray2[i].color = color;
			}, m_ColorImagesArray2[i].color, targetValue, 1.5f, (float)i * 0.5f, null, scaledTime: false, Tween.TweenType.Linear);
		}
	}

	public void Workaround2(bool isRed)
	{
		StartCoroutine(Workaround2Coroutine(isRed));
	}

	private IEnumerator Workaround2Coroutine(bool isRed)
	{
		for (int i = 0; i < m_ColorImagesArray3.Length; i++)
		{
			Workaround2Workaround(m_ColorImagesArray3[i], isRed);
			yield return new WaitForSeconds(0.5f);
		}
	}

	private void Workaround2Workaround(Image image, bool isRed)
	{
		Color targetValue = (!isRed) ? MaterialColor.blue500 : MaterialColor.red500;
		TweenManager.TweenColor(delegate(Color color)
		{
			image.color = color;
		}, image.color, targetValue, 1.5f, 0f, null, scaledTime: false, Tween.TweenType.Linear);
	}
}
